package com.googlecode.horncomb.organ.model;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.MappedSuperclass;
import javax.persistence.Table;

import com.googlecode.horncomb.organ.Group;
import com.googlecode.horncomb.organ.Membership;
import com.googlecode.horncomb.organ.Person;

/**
 * @author Daniel
 */
@Entity
@Table(name = "HCB_ORGN_MBRSHP")
@MappedSuperclass
public class DefaultMembership extends DefaultRelation<Group, Person> implements
		Membership {
	private static final long serialVersionUID = 3846526392242705285L;
	private boolean belongTo;
	private boolean master;
	/** 人员排序号 */
	public int order;

	/**
	 * {@inheritDoc}
	 */
	@Override
	public String getCategory() {
		return this.getClass().getSimpleName();
	}

	/**
	 * {@inheritDoc}
	 */
	@Column(name = "GROUP_")
	public Group getGroup() {
		return this.getSource();
	}

	/**
	 * {@inheritDoc}
	 */
	public void setGroup(Group group) {
		this.setSource(group);
	}

	/**
	 * {@inheritDoc}
	 */
	@Column(name = "PERSON_")
	public Person getPerson() {
		return this.getTarget();
	}

	/**
	 * {@inheritDoc}
	 */
	public void setPerson(Person person) {
		this.setTarget(person);
	}

	/**
	 * @return the belongTo
	 */
	@Column(name = "BELONGTO_")
	public boolean isBelongTo() {
		return belongTo;
	}

	/**
	 * @param belongTo
	 *            the belongTo to set
	 */
	public void setBelongTo(boolean belongTo) {
		this.belongTo = belongTo;
	}

	/**
	 * @return the master
	 */
	@Column(name = "MASTER_")
	public boolean isMaster() {
		return master;
	}

	/**
	 * @param master
	 *            the master to set
	 */
	public void setMaster(boolean master) {
		this.master = master;
	}

	/**
	 * @return the order
	 */
	@Column(name = "ORDER_")
	public int getOrder() {
		return order;
	}

	/**
	 * @param order the order to set
	 */
	public void setOrder(int order) {
		this.order = order;
	}
}
